package lv.senan.clients.bing;

import java.util.Iterator;

import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;

/**
 * MS Bing namespace. Most of code derived from here:
 * http://www.bing.com/community/blogs/developer/archive/2009/05/28/using-the-api-version-2-0-beta-with-java-and-the-api-s-xml-interface.aspx
 * 
 * @author Igors Gulbinskis
 */
public class BingNamespaceContext implements NamespaceContext {
	
	public final static String WEB_NAMESPACE =  "http://schemas.microsoft.com/LiveSearch/2008/04/XML/web";
	public final static String API_NAMESPACE = "http://schemas.microsoft.com/LiveSearch/2008/04/XML/element";
	public final static String SPELL_NAMESPACE = "http://schemas.microsoft.com/LiveSearch/2008/04/XML/spell";
	public final static String RS_NAMESPACE = "http://schemas.microsoft.com/LiveSearch/2008/04/XML/relatedsearch";
	public final static String PB_NAMESPACE = "http://schemas.microsoft.com/LiveSearch/2008/04/XML/phonebook";
	public final static String MM_NAMESPACE = "http://schemas.microsoft.com/LiveSearch/2008/04/XML/multimedia";
	public final static String AD_NAMESPACE = "http://schemas.microsoft.com/LiveSearch/2008/04/XML/ads";
	public final static String IA_NAMESPACE = "http://schemas.microsoft.com/LiveSearch/2008/04/XML/instantanswer";
	public final static String NEWS_NAMESPACE = "http://schemas.microsoft.com/LiveSearch/2008/04/XML/news";
	public final static String ENCARTA_NAMESPACE = "http://schemas.microsoft.com/LiveSearch/2008/04/XML/encarta";

	public String getNamespaceURI(String prefix) {
		if (prefix == null) throw new NullPointerException("Null prefix");
		else if ("api".equals(prefix)) return API_NAMESPACE;
		else if ("web".equals(prefix)) return WEB_NAMESPACE;
		return XMLConstants.NULL_NS_URI;
	}
	
	public String getPrefix(String uri)  {
		throw new UnsupportedOperationException();
	}
	
	@SuppressWarnings("unchecked")
	public Iterator getPrefixes(String arg0) {
		throw new UnsupportedOperationException();
	}
	
}